package com.zed.api.domain.repository;


import com.zed.api.common.ApplicationContextSupport;

/**
 * 应用上下文查询存储库支持类
 *
 * @author Zed
 */
public abstract class ApplicationContextQueryRepository<P, T> extends ApplicationContextSupport implements QueryRepository<P, T> {

    /**
     *
     */
    public ApplicationContextQueryRepository() {

    }

    /**
     * 按{@code beanName}获取对应的bean实例
     *
     * @param <B>
     * @param beanName {@link String},bean名称
     * @param beanType {@link Class}, bean类型
     * @return {@link B}
     */
    protected <B> B getBean(String beanName, Class<B> beanType) {
        return this.getContext().getBean(beanName, beanType);
    }

    /**
     * 按{@code beanType}获取对应的bean实例
     *
     * @param beanType {@link Class}
     * @return {@link B},转换过后的类型
     */
    protected <B> B getBean(Class<B> beanType) {
        return this.getContext().getBean(beanType);
    }
}
